﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace PreArchiveAndPrint
{
    public partial class PreArchive : Form
    {

        private string destFileName = "C:\\PreArchive\\999\\999\\dwg\\";
        private string sourceFileName = "";
        public PreArchive()
        {
            InitializeComponent();
        }

        private void radioSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb.Checked)
            {
                int len = checkedListBox1.Items.Count;
                for (int i = 0; i < len; i++)
                {
                    checkedListBox1.SetItemChecked(i, true);
                }
            }
           
           
        }

        private void bt_View_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = "C:\\Sim\\";
            //openFileDialog.Filter = "dwg (*.dwg)|pdf (*.pdf)|pft (*.plt)|dwt (*.dwt)";
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog()==DialogResult.OK||openFileDialog.ShowDialog()==DialogResult.Yes)
            {
                string[] fileNamePath = openFileDialog.FileNames;
                
                foreach (var name in fileNamePath)
                {
                  string  fileName = name.Substring(name.LastIndexOf("\\")+1);
                 
                    checkedListBox1.Items.Add(fileName);
                }
            }
            else
            {
                return;
            }
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //int len=checkedListBox1.Items.Count;
            //for (int i = 0; i < len;i++ )
            //{

            //    if (checkedListBox1.GetItemChecked(i))
            //    {
            //        destFileName += "" + checkedListBox1.Items[i].ToString();
            //        sourceFileName += "C:\\Sim\\999\\999\\Common\\TZ\\JZ\\" + checkedListBox1.Items[i].ToString();
            //        File.Copy(sourceFileName, destFileName);
            //    }
            //}
            //归档
            //PreArchiveService preArchiveService = new PreArchiveService();
            //string preArchivePath = preArchiveService.getDirectoryPath("999", "999");
            //preArchiveService.makeDirectory(preArchivePath);
            //preArchiveService.preArchive(PreArchiveConfiguration.testPath, preArchivePath);
        }

        private void radioCancelAll_CheckedChanged(object sender, EventArgs e)
        {
           
                int len = checkedListBox1.Items.Count;
                for (int i = 0; i < len; i++)
                {
                    checkedListBox1.SetItemChecked(i, false);
                }
         
        }
    }
}
